package common;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

import android.content.Context;
import db.ExeDTO;
import dominain.AbstractExeDTO;
import dominain.SystemDTO;
import error.JException;

public class CommonImpl implements Common {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getAbstractExeDTO(android.content
	 * .Context)
	 */
	@Override
	public AbstractExeDTO getAbstractExeDTO(Context context) throws JException {

		return ExeDTO.getExeDTO(context);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getTwY(com.controller.love.domain
	 * .AbstractExeDTO)
	 */
	@Override
	public String getTwY(AbstractExeDTO exe) {
		return JCommonUtils.getTwY();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getTwymd(com.controller.love.domain
	 * .AbstractExeDTO)
	 */
	@Override
	public String getTwymd(AbstractExeDTO exe) {
		return JCommonUtils.getTwymd();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getTime(com.controller.love.domain
	 * .AbstractExeDTO)
	 */
	@Override
	public String getTime(AbstractExeDTO exe) {

		return JCommonUtils.getTime();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getUserId(com.controller.love.domain
	 * .AbstractExeDTO)
	 */

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getContext(com.controller.love.domain
	 * .AbstractExeDTO)
	 */
	@Override
	public Context getContext(AbstractExeDTO exe) {
		// TODO Auto-generated method stub
		return exe.getContext();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getSystemDTO(com.controller.love
	 * .domain.AbstractExeDTO)
	 */
	@Override
	public SystemDTO getSystemDTO(AbstractExeDTO abstractExeDTO)
			throws JException {

		return abstractExeDTO.getSystemDTO();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getTxtransactionId(com.controller
	 * .love.domain.AbstractExeDTO)
	 */
	@Override
	public synchronized String getTxtransactionId(AbstractExeDTO exe) {

		final SimpleDateFormat simple = new java.text.SimpleDateFormat();

		simple.applyPattern("yyyyMMddHHmmss");

		String s = UUID.randomUUID().toString();

		return "TX" + simple.format(new Date());

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getExeDTO(android.content.Context)
	 */
	@Override
	public AbstractExeDTO getExeDTO(Context context) throws JException {
		return ExeFactory.getExe(context);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getmonth(com.controller.love.domain
	 * .AbstractExeDTO)
	 */
	@Override
	public String getmonth(AbstractExeDTO exe) {
		// TODO Auto-generated method stub
		return JCommonUtils.getTwMon();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.controller.love.component.Common#getday(com.controller.love.domain
	 * .AbstractExeDTO)
	 */
	@Override
	public String getday(AbstractExeDTO exe) {
		// TODO Auto-generated method stub
		return JCommonUtils.getTwDay();
	}
}
